<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use app\controller\CaptchaController;
use app\controller\CityListController;
use app\controller\HomeNavImgController;
use app\controller\UserController;
use think\facade\Route;

Route::get('think', function () {
    return 'hello,ThinkPHP8!';
});

Route::get('hello/:name', 'index/hello');



// 对路由进行分组
Route::group('/api', function () {
    //获取验证码的
    Route::get('/captcha', [CaptchaController::class, 'generate']);
//    Route::post('captcha/verify', [CaptchaController::class, 'verify']);
// 注册路由
    Route::post('/auth/register', [UserController::class,'register']);
// 登录
    Route::post('/auth/login', [UserController::class,'login']);
    // 注销
    Route::post('/auth/logout', [UserController::class,'logout']);

//拿到轮播图的三张为热门旅游地
    Route::get('/lists',function (){
        try {
            $res =  \think\facade\Db::table('home_nav_img')->limit(3)->select();
        }catch (\Exception $e){
            return json([
                "code" => 400,
                "msg" => $e->getMessage()
            ]);
        }

       return json([
           "code" => 200,
           "data" => $res,
           "message" => "页面获取成功！"
       ]);
    })->middleware("check");

//    月份推荐的信息
    Route::get('/base/lists',[CityListController::class,'baseLists'])->middleware("check");
//  热度排行，现在先全部取，后面取100条数据
    Route::get('/hot/top',[CityListController::class,'hotTop'])->middleware("check");
//    这个是写判断是哪一个获取数据，需要根据邮箱来判断
    Route::get('/like/list',[CityListController::class,'likeList'])->middleware("check");
//    查看用户发布了多少个旅游景点、
    Route::get('/my/list',[CityListController::class,'myList'])->middleware("check");
//    返回省市区的城市列表
    Route::get('/city/name',[\app\controller\CityController::class,'city_name'])->middleware("check");

//    给传过来id页面的点击量+1，表示只要点击了这个页面，就让页面值+1
    Route::post('/add/top',[CityListController::class,'addTop'])->middleware("check");

//    添加旅游列表的信息
    Route::post('/upload/list',[CityListController::class,'uploadList'])->middleware("check");

//    轮播图的资源路由
    Route::resource('/home_nav_img', HomeNavImgController::class)->middleware("check");
//    列表的路由城市列表的资源路由
    Route::resource('/cityList', CityListController::class)->middleware("check");
//    中间表(user_city)的资源路由
    Route::resource('/like/city', \app\controller\LikeCityListController::class)->middleware("check");

});
